import request from '@/utils/request'
import qs from 'qs'

/**
 * 登录
 * @returns {AxiosPromise}
 */
export const reqLogin = (data) =>
  request({
    url: '/api/login?' + qs.stringify(data),
    method: 'post'
  })

/**
 * 退出
 * @returns {AxiosPromise}
 */
export const reqLogout = () =>
  request({
    url: '/api/logout',
    method: 'post'
  })

/**
 * 验证码
 * @returns {AxiosPromise}
 */
export const reqGetCaptcha = () =>
  request({
    url: '/api/captcha',
    method: 'get'
  })

/**
 * 获取菜单树
 * @returns {AxiosPromise}
 */
export const reqGetMenuQueryTree = () =>
  request({
    url: '/api/basics/menu/queryTree',
    method: 'get'
  })

/**
 * 根据角色id查询权限数组
 * @returns {AxiosPromise}
 */
export const reqGetRoleQueryRoleIdByMenuIds = (roleId) =>
  request({
    url: '/api/basics/role/queryRoleIdByMenuIds/' + roleId,
    method: 'get'
  })

/**
 * 根据角色id查询权限数组
 * @returns {AxiosPromise}
 */
export const reqSetRoleAddMenu = (roleId, menuIds) =>
  request({
    url: '/api/basics/role/roleAddMenu/' + roleId,
    method: 'put',
    data: menuIds
  })

export const getRole = () =>
  request({
    url: '/api/basics/basics/role/page',
    method: 'get'
  })

export const queryDicNameByDicCode = (data) =>
  request({
    url: '/apibasics/dictionary/queryDicNameByDicCode',
    method: 'get',
    params: data
  })
